ImagXpress® provides a suite of methods and properties that enable adjustment of image color. The color of each pixel in an image can be characterized using various color spaces. The Processor class enables the user to modify the color balance within an image by specifying either of the following color spaces:
- RGB specifies the red, green and blue values within the pixel.
- HSL specifies the hue (color tone), saturation (grayness), and luminance (intensity of light).
Modify RGB Levels
To change the levels of red, green and blue in the image, call AdjustRGB method, specifying the amount of change to the red, green and blue components of each pixel (in units or by percentage). Use the RGBColorCount method to identify the red, green, and blue color intensities of the image. This is useful in determining how to set parameters.
Modify HSL Levels
To change the levels of hue, saturation and luminance in the image, call AdjustHSL, specifying the amount of change to the hue, saturation and luminance components of each pixel (in units or by percentage).
Modify Luminance/Brightness
The Brightness method uniformly brightens the current image, by the percent specified. A brightened image has pixels with higher luminance values (in HSL color space), or higher RGB values (in RGB color space) than the original image.
Automatic Color Balance
The Processor object provides two alternative automatic color balance methods. Each uses a different algorithm to correct color balance. The user has the flexibility to use whichever method works best for the application and image:
-
To balance automatically, call AutoColorBalance. To override the default parameters used in the AutoColorBalance algorithm, call AdjustColorBalance instead of AutoColorBalance. The RGBColorCount method can be used to identify the red, green and blue color intensities of the image. This may be useful in determining how to set parameters specified in AdjustColorBalance.
-
To color balance automatically using an alternative algorithm, call AutoLevel.
Automatic Contrast Correction
The Processor class provides three alternative automatic contrast correction methods. Each uses a different algorithm to correct contrast within the image. The user has the flexibility to use whichever method works best for the application and image:
-
The AutoLightness method assesses and adjusts contrast in light and dark regions of the image separately. This can be especially useful for bringing more detail into the shadowy areas of the image, without washing out the light regions. To override the default parameters used in the AutoLightness algorithm, call AdjustLightness instead of AutoLightness.
- The AutoContrast method adjusts the overall contrast of the image. To adjust the automatic contrast correction by a specified amount, call Contrast instead of AutoContrast.
- The Equalize method adjusts contrast without changing the brightness range of the image. If the brightness values of the image were represented in a histogram, the Equalize method would have the effect of redistributing the brightness values within the image's brightness range, so that "clumps" of brightness values are spread out more evenly. For example, if an image has many pixels that have similar brightness, the Equalize method will introduce greater difference in brightness between these pixels, without changing the least bright or most bright pixels. The effect is that greater detail can be seen in areas that previously had very similar brightness.
Modify Gamma
Unfortunately, monitors may output pixel brightness in a non-linear fashion, so that when the image is displayed, the image brightness is not accurately portrayed. Adjusting gamma enables the user to adjust pixel brightness to compensate for the limitations of the display device. The gamma value represents the ratio of input vs. output brightness.
A gamma of one represents a linear relationship between input and output brightness - no change is made to the image. A gamma other than one represents a parabolic relationship between input and output brightness. Applying a gamma greater than one brightens the image, with mid-brightness levels increased more than extremely dark or light pixels. A gamma less than one darkens the image, with mid-brightness levels decreased more than extremely dark or light pixels.
The Gamma method adjusts the brightness of the image based on a parabolic transform, defined by the gamma value. A Gamma value that is greater than one will result in a convex parabolic transform, with the mid-range brightened more than high and low end. A Gamma value that is less than one will result in a concave parabolic transform, with the mid-range darkened more than the high and low end.
Join or Split RGB Values
The Processor class also provides the capability to split or join the RGB values of the pixels in the image. To separate the color components of the image, call ColorSeparation. To join the color components of the image, call ColorJoin.
You must free the resources associated with each color plane bitmap after it is no longer needed. Call ImageX.DisposeHbitmap to release the resources associated with the handles after use. |
Count Colors
The ColorCount method returns the number of pixels of a specified color within the current image or region. This can be useful, for example, in determining whether a check box on a form is filled.